package react.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import react.model.Employee;
import react.repository.EmployeeRepository;

/**
 * Created by tiansha on 2016/4/18.
 */
@RestController
@RequestMapping("/api/employees")
public class EmployeeResource {

  @Autowired
  private EmployeeRepository employeeRepository;

  @RequestMapping(method= RequestMethod.GET)
  public Page<Employee> getEntryByPageable(@PageableDefault(value = 4, sort = { "id" }, direction = Sort.Direction.ASC)
                                             Pageable pageable) {
    return employeeRepository.findAll(pageable);
  }
}
